package com.lc.qianrenshiye.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.lc.qianrenshiye.R;
import com.lc.qianrenshiye.conn.CutPriceListPost;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * Created by Administrator on 2016/12/1.
 */
public class CutPopAdapter extends ArrayAdapter<CutPriceListPost.PercentPriceEntity> {

    private LayoutInflater layoutInflater;
    private Context contex;

    public CutPopAdapter(Context context, List<CutPriceListPost.PercentPriceEntity> poplists) {
        super(context, 0, poplists);

        this.contex = context;

        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        CutPriceListPost.PercentPriceEntity percentPriceEntity = getItem(position);

        ViewHolder viewHolder;

        if (convertView == null) {

            convertView = BoundViewHelper.boundView(viewHolder = new ViewHolder(), ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) layoutInflater.inflate(R.layout.item_pop_cut_list, null)));

            convertView.setTag(viewHolder);

        } else {

            viewHolder = (ViewHolder) convertView.getTag();

        }

        viewHolder.item_pop_cut_list_tv.setText(Float.parseFloat(percentPriceEntity.percent) / 10 + "折");

        return convertView;
    }

    class ViewHolder {

        @BoundView(R.id.item_pop_cut_list_tv) private TextView item_pop_cut_list_tv;

    }

}
